package com.util;

import java.util.Calendar;
import java.util.Comparator;

import com.entity.FileInfo;

/** 排序 **/
public class FileComparator implements Comparator<FileInfo> {

	public int compare(FileInfo file1, FileInfo file2) {
		// // 文件夹排在前面
		// if (file1.IsDirectory && !file2.IsDirectory) {
		// return -1000;
		// } else if (!file1.IsDirectory && file2.IsDirectory) {
		// return 1000;
		// }
		// // 相同类型按名称排序
		// return file1.Name.compareTo(file2.Name);
		Calendar cal = Calendar.getInstance();
		cal.setTimeInMillis(file1.motifyTime);
		Calendar ca2 = Calendar.getInstance();
		cal.setTimeInMillis(file2.motifyTime);
		int flag = cal.getTime().toGMTString().compareTo(ca2.getTime().toGMTString());
		return flag;
	}
}